3 <script src="../lib/OpenLayers.js"></script>
4 <script type="text/javascript">
6 function test_Rule_constructor(t) {
9 var options = {'foo': 'bar'};
10 var rule = new OpenLayers.Rule(options);
11 t.ok(rule instanceof OpenLayers.Rule,
12 "new OpenLayers.Rule returns object" );
13 t.eq(rule.foo, "bar", "constructor sets options correctly");
14 t.eq(typeof rule.evaluate, "function", "rule has an evaluate function");
17 function test_Rule_getContext(t) {
28 rule = new OpenLayers.Rule();
29 var context = rule.getContext(feature);
30 t.eq(context.dude, "hello", "value returned by getContext is correct"
31 + " if no context is specified");
34 context: function(feature){
38 rule = new OpenLayers.Rule(options);
39 var context = rule.getContext(feature);
40 t.eq(context.foobar, "world", "value returned by getContext is correct"
41 + " if a context is given in constructor options");
44 function test_clone(t) {
48 var rule = new OpenLayers.Rule({
50 minScaleDenominator: 10,
51 maxScaleDenominator: 20,
52 filter: new OpenLayers.Filter.Comparison({
53 type: OpenLayers.Filter.Comparison.EQUAL_TO,
64 var clone = rule.clone();
65 t.eq(clone.name, "test rule", "name copied");
66 t.eq(clone.minScaleDenominator, 10, "minScaleDenominator copied");
67 t.eq(clone.filter.type, OpenLayers.Filter.Comparison.EQUAL_TO, "clone has correct filter type");
70 rule.filter.property = "new";
71 rule.symbolizer.fillColor = "white";
72 rule.context.foo = "baz";
74 // confirm that clone didn't change
75 t.eq(clone.filter.property, "prop", "clone has clone of filter");
76 t.eq(clone.symbolizer.fillColor, "black", "clone has clone of symbolizer");
77 t.eq(clone.context.foo, "bar", "clone has clone of context");
79 // confirm that ids are different
80 t.ok(clone.id !== rule.id, "clone has different id");
87 function test_Rule_destroy(t) {
90 var rule = new OpenLayers.Rule();
92 t.eq(rule.symbolizer, null, "symbolizer hash nulled properly");