Skip to content

Commit

Permalink
Remove can imports from all the tests, fix up other breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
BigAB committed Mar 16, 2016
1 parent cd0a4ff commit c45fd93
Show file tree
Hide file tree
Showing 62 changed files with 553 additions and 577 deletions.
1 change: 0 additions & 1 deletion component/component_bindings_test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* jshint -W003 */
var can = require('can');
require("can/map/define/define");
require("can/component/component");
require("can/view/stache/stache");
Expand Down
1 change: 0 additions & 1 deletion component/component_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
var can = require('can');
require("can/util/vdom/document/document");
require("can/util/vdom/build_fragment/build_fragment");
require("can/map/define/define");
Expand Down
1 change: 0 additions & 1 deletion compute/compute_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
var can = require('can/util/util');
require('can/compute/compute');
require('can/map/map');
require('steal-qunit');
Expand Down
1 change: 0 additions & 1 deletion compute/read_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
var can = require('can/util/util');
require('can/compute/compute');
require('can/map/map');
require('steal-qunit');
Expand Down
1 change: 1 addition & 0 deletions construct/proxy/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ var isFunction = can.isFunction,
return cur;
};
};

can.Construct.proxy = can.Construct.prototype.proxy = proxy;
// this corrects the case where can/control loads after can/construct/proxy, so static props don't have proxy
var correctedClasses = [
Expand Down
23 changes: 14 additions & 9 deletions construct/proxy/proxy_test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
/* global Car */
// require('can/construct/construct');
require('can/construct/proxy/proxy');
require('can/control/control');
require('steal-qunit');

QUnit.module('can/construct/proxy');

test('static proxy if control is loaded first', function () {
var curVal = 0;
expect(2);
Expand Down Expand Up @@ -35,12 +37,15 @@ test('proxy', function () {
cb2();
});

test('proxy error', 1, function () {
can.Construct('Car', {});
try {
Car.proxy('huh');
ok(false, 'I should have errored');
} catch (e) {
ok(true, 'Error was thrown');
}
});
// this won't work in dist mode (this functionality is removed)
if (typeof steal !== 'undefined') {
test('proxy error', 1, function () {
can.Construct('Car', {});
try {
Car.proxy('huh');
ok(false, 'I should have errored');
} catch (e) {
ok(true, 'Error was thrown');
}
});
}
1 change: 0 additions & 1 deletion control/modifier/modifier_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
var can = require('can/util/util');
require('can/control/modifier/modifier');
require('can/util/event');
require('steal-qunit');
Expand Down
3 changes: 3 additions & 0 deletions control/plugin/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ var $ = require('jquery');
var can = require('can/util/util');
require('can/control/control');


$ = $ || window.$;

//used to determine if a control instance is one of controllers
//controllers can be strings or classes
var i, isAControllerOf = function (instance, controllers) {
Expand Down
195 changes: 101 additions & 94 deletions control/plugin/plugin_test.js
Original file line number Diff line number Diff line change
@@ -1,104 +1,111 @@
/* jshint -W079 */
/* global My */
var can = require('can/util/util');
var $ = require('jquery');
require('can/control/plugin/plugin');
require('steal-qunit');

QUnit.module('can/control/plugin');
test('pluginName', function () {
expect(8);
can.Control('My.TestPlugin', {
pluginName: 'my_plugin'
}, {
init: function (el, ops) {
ok(true, 'Init called');
equal(ops.testop, 'testing', 'Test argument set');
},
method: function (arg) {
ok(true, 'Method called');
equal(arg, 'testarg', 'Test argument passed');
},
update: function (options) {
ok(true, 'Update called');
}

if (window.jQuery) {

test('pluginName', function() {
expect(8);
can.Control('My.TestPlugin', {
pluginName: 'my_plugin'
}, {
init: function(el, ops) {
ok(true, 'Init called');
equal(ops.testop, 'testing', 'Test argument set');
},
method: function(arg) {
ok(true, 'Method called');
equal(arg, 'testarg', 'Test argument passed');
},
update: function(options) {
ok(true, 'Update called');
}
});
var ta = can.$('<div/>')
.addClass('existing_class')
.appendTo($('#qunit-fixture'));
ta.my_plugin({
testop: 'testing'
});
// Init
ok(ta.hasClass('my_plugin'), 'Should have class my_plugin');
ta.my_plugin();
// Update
ta.my_plugin('method', 'testarg');
// method()
ta.control()
.destroy();
// destroy
ok(!ta.hasClass('my_plugin'), 'Shouldn\'t have class my_plugin after being destroyed');
ok(ta.hasClass('existing_class'), 'Existing class should still be there');
});
test('.control(), .controls() and _fullname', function() {
expect(3);
can.Control('My.TestPlugin', {});
var ta = can.$('<div/>')
.appendTo($('#qunit-fixture'));
ok(ta.my_test_plugin, 'Converting Control name to plugin name worked');
ta.my_test_plugin();
equal(ta.controls()
.length, 1, '.controls() returns one instance');
ok(ta.control() instanceof My.TestPlugin, 'Control is instance of test plugin');
});
var ta = can.$('<div/>')
.addClass('existing_class')
.appendTo($('#qunit-fixture'));
ta.my_plugin({
testop: 'testing'
test('update', function() {
can.Control({
pluginName: 'updateTest'
}, {});
var ta = can.$('<div/>')
.addClass('existing_class')
.appendTo($('#qunit-fixture'));
ta.updateTest();
// Init
ta.updateTest({
testop: 'testing'
});
equal(ta.control()
.options.testop, 'testing', 'Test option has been extended properly');
});
// Init
ok(ta.hasClass('my_plugin'), 'Should have class my_plugin');
ta.my_plugin();
// Update
ta.my_plugin('method', 'testarg');
// method()
ta.control()
.destroy();
// destroy
ok(!ta.hasClass('my_plugin'), 'Shouldn\'t have class my_plugin after being destroyed');
ok(ta.hasClass('existing_class'), 'Existing class should still be there');
});
test('.control(), .controls() and _fullname', function () {
expect(3);
can.Control('My.TestPlugin', {});
var ta = can.$('<div/>')
.appendTo($('#qunit-fixture'));
ok(ta.my_test_plugin, 'Converting Control name to plugin name worked');
ta.my_test_plugin();
equal(ta.controls()
.length, 1, '.controls() returns one instance');
ok(ta.control() instanceof My.TestPlugin, 'Control is instance of test plugin');
});
test('update', function () {
can.Control({
pluginName: 'updateTest'
}, {});
var ta = can.$('<div/>')
.addClass('existing_class')
.appendTo($('#qunit-fixture'));
ta.updateTest();
// Init
ta.updateTest({
testop: 'testing'
test('calling methods', function() {
can.Control({
pluginName: 'callTest'
}, {
returnTest: function() {
return 'Hi ' + this.name;
},
setName: function(name) {
this.name = name;
}
});
var ta = can.$('<div/>')
.appendTo($('#qunit-fixture'));
ta.callTest();
ok(ta.callTest('setName', 'Tester') instanceof $, 'Got jQuery element as return value');
equal(ta.callTest('returnTest'), 'Hi Tester', 'Got correct return value');
});
equal(ta.control()
.options.testop, 'testing', 'Test option has been extended properly');
});
test('calling methods', function () {
can.Control({
pluginName: 'callTest'
}, {
returnTest: function () {
return 'Hi ' + this.name;
},
setName: function (name) {
this.name = name;
}
test('always use pluginName first in .control(name) (#448)', 4, function() {
can.Control('SomeName', {
pluginName: 'someTest'
}, {});
can.Control({
pluginName: 'otherTest'
}, {});
var ta = can.$('<div/>')
.appendTo($('#qunit-fixture'));
ta.someTest();
ta.otherTest();
var control = ta.control('someTest');
ok(control, 'Got a control from pluginName');
equal(control.constructor.pluginName, 'someTest', 'Got correct control');
control = ta.control('otherTest');
ok(control, 'Got a control from pluginName');
equal(control.constructor.pluginName, 'otherTest', 'Got correct control');
});

} else {
test('dont test anything', function(){
ok(true);
});
var ta = can.$('<div/>')
.appendTo($('#qunit-fixture'));
ta.callTest();
ok(ta.callTest('setName', 'Tester') instanceof $, 'Got jQuery element as return value');
equal(ta.callTest('returnTest'), 'Hi Tester', 'Got correct return value');
});
test('always use pluginName first in .control(name) (#448)', 4, function () {
can.Control('SomeName', {
pluginName: 'someTest'
}, {});
can.Control({
pluginName: 'otherTest'
}, {});
var ta = can.$('<div/>')
.appendTo($('#qunit-fixture'));
ta.someTest();
ta.otherTest();
var control = ta.control('someTest');
ok(control, 'Got a control from pluginName');
equal(control.constructor.pluginName, 'someTest', 'Got correct control');
control = ta.control('otherTest');
ok(control, 'Got a control from pluginName');
equal(control.constructor.pluginName, 'otherTest', 'Got correct control');
});
}
2 changes: 1 addition & 1 deletion event/propagate/propagate_test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var can = require('can/util/util');
var event = require('can/event/propagate/propagate');
require('can/test/test');
require('steal-qunit');

QUnit.module('can/event/propagate');
Expand Down
1 change: 0 additions & 1 deletion list/list_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
var can = require('can/util/util');
require('can/list/list');
require('can/compute/compute');
require('steal-qunit');
Expand Down
1 change: 0 additions & 1 deletion list/promise/promise_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
var can = require('can/util/util');
require('can/list/promise/promise');
require('can/compute/compute');
require('steal-qunit');
Expand Down
1 change: 0 additions & 1 deletion list/sort/sort_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
var can = require('can');
require('can/list/sort/sort');
require('can/view/stache/stache');
require('can/model/model');
Expand Down
1 change: 0 additions & 1 deletion map/attributes/attributes_test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*jshint undef:false,unused:false*/
var can = require('can/util/util');
require('can/map/attributes/attributes');
require('can/model/model');
require('can/util/fixture/fixture');
Expand Down
1 change: 0 additions & 1 deletion map/backup/backup_test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*global Recipe*/
var can = require('can/util/util');
require('can/map/backup/backup');
require('can/model/model');
require('steal-qunit');
Expand Down
Loading

0 comments on commit c45fd93

Please sign in to comment.