Skip to content

Commit

Permalink
updated unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
beatfactor committed Oct 4, 2015
1 parent 6408fbe commit 2589625
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions tests/run_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ try {
server.on('listening', function() {
reporter.run([
'src',
'src/runner',
'src/mocha',
'src/expect',
'src/protocol',
Expand Down
2 changes: 1 addition & 1 deletion tests/sampletests/withchaiexpect/sampleWithChai.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
client.url('http://localhost')
.elements('css selector', '#weblogin', function(result) {
var assertion = client.expect(result.value).to.have.length(1);
client.globals.test.deepEqual(assertion.__flags.object, { ELEMENT: '0' });
client.globals.test.deepEqual(assertion.__flags.object, [{ ELEMENT: '0' }]);
try {
client.expect(result.value).to.have.length(2);
} catch (ex) {
Expand Down
9 changes: 8 additions & 1 deletion tests/src/runner/testClientManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ module.exports = {
mockery.enable({ useCleanCache: true, warnOnUnregistered: false });
function Nightwatch(opts) {
this.results = {};
this.terminated = true;
this.api = {
currentTest : {}
};

this.queue = {
run : function() {},
reset : function() {},
Expand All @@ -24,6 +26,10 @@ module.exports = {
Nightwatch.prototype.endSessionOnFail = function() {};
Nightwatch.prototype.printResult = function() {};
Nightwatch.prototype.clearResult = function() {};
Nightwatch.prototype.resetTerminated = function() {
this.terminated = false;
return this;
};

mockery.registerMock('../index.js', {
client : function(opts) {
Expand All @@ -42,12 +48,13 @@ module.exports = {
},

'test start with callback on success' : function(test) {
test.expect(1);
test.expect(2);

var ClientManager = require('../../../'+ BASE_PATH +'/runner/clientmanager.js');
var client = new ClientManager();
client.init({});
client.start(function() {
test.equals(client['@client'].terminated, false);
test.equals(arguments.length, 0);
test.done();
});
Expand Down
6 changes: 3 additions & 3 deletions tests/src/runner/testParallelExecution.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ module.exports = {
});

runner.setup({}, function() {
test.equals(self.allArgs.length, 18);
test.equals(self.allArgs.length, 20);
test.ok(path.join('sampletests', 'async', 'sample_1') in runner.runningProcesses);
test.ok(path.join('sampletests', 'before-after', 'sampleSingleTest_2') in runner.runningProcesses);

Expand Down Expand Up @@ -144,7 +144,7 @@ module.exports = {

runner.setup({}, function() {
test.ok(!runner.isParallelMode());
test.equals(self.allArgs.length, 18);
test.equals(self.allArgs.length, 20);
test.done();
});

Expand All @@ -169,7 +169,7 @@ module.exports = {

runner.setup({}, function() {
test.ok(!runner.isParallelMode());
test.equals(self.allArgs.length, 18);
test.equals(self.allArgs.length, 20);
test.done();
});

Expand Down
5 changes: 2 additions & 3 deletions tests/src/runner/testRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -813,20 +813,19 @@ module.exports = {

testRunWithChaiExpect : function(test) {
var testsPath = path.join(process.cwd(), '/sampletests/withchaiexpect');
//test.expect(7);
test.expect(6);

this.Runner.run([testsPath], {
seleniumPort : 10195,
silent : true,
output : true,
output : false,
globals : {
test : test
}
}, {
output_folder : false,
start_session : true
}, function(err, results) {
console.log(results)
test.equals(err, null);
test.equals(results.modules.sampleWithChai.tests, 2);
test.equals(results.modules.sampleWithChai.failures, 0);
Expand Down

0 comments on commit 2589625

Please sign in to comment.