Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update practiceSpec.js #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions test/spec/practiceSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ describe('callbackPractice', function () {
expect(first).toEqual(jasmine.any(Function));
})
it('should return the first item of a passed array to the callback', function () {
var arr = ['test', 'no'];
var callback = jasmine.createSpy(function (str) {
let arr = ['test', 'no'];
let callback = jasmine.createSpy(function (str) {
return str
})
var test = first(arr, callback);
let test = first(arr, callback);
expect(callback).toHaveBeenCalledWith('test');
})
})
Expand All @@ -19,11 +19,11 @@ describe('callbackPractice', function () {
expect(last).toEqual(jasmine.any(Function));
})
it('should return the last item of a passed array to the callback', function () {
var arr = ['test', 'no'];
var callback = jasmine.createSpy(function (str) {
let arr = ['test', 'no'];
let callback = jasmine.createSpy(function (str) {
return str
})
var test = last(arr, callback);
let test = last(arr, callback);
expect(callback).toHaveBeenCalledWith('no');
})
})
Expand All @@ -33,15 +33,15 @@ describe('callbackPractice', function () {
expect(multiply).toEqual(jasmine.any(Function));
})
it('should multiply the first two parameters and pass the result to the callback', function () {
var callback = jasmine.createSpy(function (num) {
let callback = jasmine.createSpy(function (num) {
return num
})
var test = multiply(25, 4, callback);
let test = multiply(25, 4, callback);
expect(callback).toHaveBeenCalledWith(100);
})
})
describe('contains', function () {
var arr, callback;
let arr, callback;
beforeEach(function () {
callback = jasmine.createSpy(function (bool) {
return bool
Expand All @@ -58,16 +58,16 @@ describe('callbackPractice', function () {
expect(callback).toHaveBeenCalledWith(jasmine.any(Boolean));
})
it('should return true to the callback if the name is in the array', function () {
var trueTest = contains(arr, 'tester', callback);
let trueTest = contains(arr, 'tester', callback);
expect(callback).toHaveBeenCalledWith(true);
})
it('should return false to the callback if the name is not in the array', function () {
var falseTest = contains(arr, 'craig', callback);
let falseTest = contains(arr, 'craig', callback);
expect(callback).toHaveBeenCalledWith(false);
})
})
describe('uniq', function () {
var arr, callback;
let arr, callback;
beforeEach(function () {
callback = jasmine.createSpy(function (arr) {
return arr;
Expand All @@ -84,12 +84,12 @@ describe('callbackPractice', function () {
})
it('should return an array to the callback where all duplicates are removed', function () {
uniq(arr, callback);
var expected = ['tester', 'alice', 'bob', 'charlie', 'danielle']
let expected = ['tester', 'alice', 'bob', 'charlie', 'danielle']
expect(callback.calls.argsFor(0)[0].sort()).toEqual(expected.sort())
})
})
describe('each', function () {
var arr, callback;
let arr, callback;
beforeEach(function () {
callback = jasmine.createSpy(function (item, index) {
return;
Expand All @@ -110,7 +110,7 @@ describe('callbackPractice', function () {
})
})
describe('getUserById', function () {
var arr, callback;
let arr, callback;
beforeEach(function () {
callback = jasmine.createSpy(function (obj) {
return;
Expand Down Expand Up @@ -151,4 +151,4 @@ describe('callbackPractice', function () {
expect(callback.calls.argsFor(0)[0].hasOwnProperty('name')).toBe(true);
})
})
})
})