0

I have a Dart file:

import 'dart:async'; 
import 'dart:html'; 
import 'dart:convert'; 
import 'package:polymer/polymer.dart';


SelectElement rplanSelector; 
ButtonElement editButton; 
var errorField; 


void main() {

      // init Polymer
      initPolymer().run(() {
        initGlobals();
        ...
      });

    }

    void initGlobals() {
      rplanSelector = querySelector('#rplanSelector'); // global
      editButton = querySelector('#editButton'); // global
      errorField = querySelector('#errorText'); // global
      errorField.style.color = 'red';
    }

What is the right way to write unit tests for this function in Dart? I need an example only, to understand a right way to do it. For examle, I wish to check that rplanSelector, editButton, errorField are not null and errorField.style.color = 'red'. Thanks.

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
  • I think you should improve this question. What are the expectations/what values are expected be set to the fields? Where are the fields. What have you tried, where are you stuck? Where is this code called from? Do you use Polymer, Angular, plain `dart:html'`? – Günter Zöchbauer Apr 15 '15 at 07:41
  • So you are using Polymer. Are the elements you querying also Polymer elements? – Günter Zöchbauer Apr 15 '15 at 07:56
  • This is a very similar question http://stackoverflow.com/questions/27404245 There are a lot of examples in the https://github.com/dart-lang/core-elements/tree/master/test package. – Günter Zöchbauer Apr 15 '15 at 07:58

0 Answers0