-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: remove enzyme enzyme-adapter-react-16 and sinon from dependenc…
…ies and replace last sinon.fakeServer for msw
- Loading branch information
Showing
7 changed files
with
126 additions
and
532 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,100 +1,92 @@ | ||
import Cookies from 'js-cookie'; | ||
import Project from 'models/project'; | ||
import PastIteration from 'models/pastIteration'; | ||
import { server } from '../mocks/server'; | ||
import { http, HttpResponse } from 'msw'; | ||
|
||
describe('PastIteration model', function() { | ||
describe('PastIteration model', function () { | ||
let project; | ||
let pastIterations; | ||
|
||
beforeEach(function() { | ||
Cookies.set('current_flow', 'progress_to_left', {expires: 365}); | ||
beforeEach(function () { | ||
Cookies.set('current_flow', 'progress_to_left', { expires: 365 }); | ||
|
||
project = new Project({ | ||
id: 1337, title: 'Test project', point_values: [0, 1, 2, 3], | ||
last_changeset_id: null, iteration_start_day: 1, iteration_length: 1, | ||
id: 1337, | ||
title: 'Test project', | ||
point_values: [0, 1, 2, 3], | ||
last_changeset_id: null, | ||
iteration_start_day: 1, | ||
iteration_length: 1, | ||
default_flow: Cookies.get('current_flow'), | ||
current_flow: Cookies.get('current_flow') | ||
current_flow: Cookies.get('current_flow'), | ||
}); | ||
|
||
pastIterations = new PastIteration({ | ||
project: project, | ||
startDate: Date.now(), | ||
endDate: Date.now() + 7, | ||
points: 3, | ||
iterationNumber: 2 | ||
project: project, | ||
startDate: Date.now(), | ||
endDate: Date.now() + 7, | ||
points: 3, | ||
iterationNumber: 2, | ||
}); | ||
}); | ||
|
||
describe('when instantiated', function() { | ||
|
||
it("should exhibit attributes", function() { | ||
describe('when instantiated', function () { | ||
it('should exhibit attributes', function () { | ||
expect(pastIterations.get('number')).toEqual(2); | ||
}); | ||
|
||
it("should have a default load state", function() { | ||
it('should have a default load state', function () { | ||
expect(pastIterations.get('needsLoad')).toBe(true); | ||
}); | ||
|
||
it("should have a default column", function() { | ||
it('should have a default column', function () { | ||
expect(pastIterations.get('column')).toBe('#done'); | ||
}); | ||
}); | ||
|
||
describe('stories', function() { | ||
|
||
it('should return the models stories', function() { | ||
describe('stories', function () { | ||
it('should return the models stories', function () { | ||
expect(pastIterations.stories()).toEqual(pastIterations._stories); | ||
}); | ||
|
||
}); | ||
|
||
describe('startDate', function() { | ||
|
||
it('should return the models start date', function() { | ||
describe('startDate', function () { | ||
it('should return the models start date', function () { | ||
expect(pastIterations.startDate()).toEqual(pastIterations._startDate); | ||
}); | ||
|
||
}); | ||
|
||
describe('endDate', function() { | ||
|
||
it('should return the models end date', function() { | ||
describe('endDate', function () { | ||
it('should return the models end date', function () { | ||
expect(pastIterations.endDate()).toEqual(pastIterations._endDate); | ||
}); | ||
|
||
}); | ||
|
||
describe('points', function() { | ||
|
||
it('should return the model points', function() { | ||
describe('points', function () { | ||
it('should return the model points', function () { | ||
expect(pastIterations.points()).toEqual(pastIterations._points); | ||
}); | ||
|
||
}); | ||
|
||
describe('fetch', function() { | ||
|
||
it('should update the stories from the iteration', function(done) { | ||
var story = [ { story:{id:42,title:"Test story"} } ]; | ||
var stories = { stories:story } | ||
var server = sinon.fakeServer.create(); | ||
|
||
server.respondImmediately = true; | ||
server.respondWith( | ||
"GET", /\/project_boards\/1337\/iterations(.*)/, [ | ||
200, {"Content-Type": "application/json"}, | ||
JSON.stringify(stories) | ||
] | ||
describe('fetch', function () { | ||
it('should update the stories from the iteration', function (done) { | ||
var story = [{ story: { id: 42, title: 'Test story' } }]; | ||
var stories = { stories: story }; | ||
server.use( | ||
http.get(/\/project_boards\/1337\/iterations(.*)/, () => { | ||
return HttpResponse.json(stories), { status: 200 }; | ||
}) | ||
); | ||
|
||
var initialStoriesLength = pastIterations._stories.length; | ||
|
||
pastIterations.fetch() | ||
.then(() => { | ||
expect(pastIterations._stories.length).toEqual(initialStoriesLength + 1); | ||
done(); | ||
}); | ||
pastIterations.fetch().then(() => { | ||
expect(pastIterations._stories.length).toEqual( | ||
initialStoriesLength + 1 | ||
); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,79 @@ | ||
import Cookies from 'js-cookie'; | ||
import Project from 'models/project'; | ||
import ProjectBoard from 'models/projectBoard'; | ||
import { server } from '../mocks/server'; | ||
import { http, HttpResponse } from 'msw'; | ||
|
||
describe('ProjectBoard model', function() { | ||
describe('ProjectBoard model', function () { | ||
let project; | ||
let projectBoard; | ||
|
||
beforeEach(function() { | ||
Cookies.set('current_flow', 'progress_to_left', {expires: 365}); | ||
beforeEach(function () { | ||
Cookies.set('current_flow', 'progress_to_left', { expires: 365 }); | ||
|
||
project = new Project({ | ||
id: 1337, title: 'Test project', point_values: [0, 1, 2, 3], | ||
last_changeset_id: null, iteration_start_day: 1, iteration_length: 1, | ||
id: 1337, | ||
title: 'Test project', | ||
point_values: [0, 1, 2, 3], | ||
last_changeset_id: null, | ||
iteration_start_day: 1, | ||
iteration_length: 1, | ||
default_flow: Cookies.get('current_flow'), | ||
current_flow: Cookies.get('current_flow') | ||
current_flow: Cookies.get('current_flow'), | ||
}); | ||
|
||
projectBoard = new ProjectBoard({project: project}); | ||
projectBoard = new ProjectBoard({ project: project }); | ||
}); | ||
|
||
describe('when instantiated', function() { | ||
|
||
it('should set up a story collection', function() { | ||
describe('when instantiated', function () { | ||
it('should set up a story collection', function () { | ||
expect(projectBoard.stories).toBeDefined(); | ||
}); | ||
|
||
it('should have a project', function() { | ||
it('should have a project', function () { | ||
expect(projectBoard.project).toBe(project); | ||
expect(projectBoard.stories.project).toBe(project); | ||
}); | ||
|
||
it("should have a default past iterations empty array", function() { | ||
it('should have a default past iterations empty array', function () { | ||
expect(projectBoard.pastIterations).toEqual([]); | ||
}); | ||
|
||
}); | ||
|
||
describe('fetch', function() { | ||
|
||
it('should update the past iterations and stories of the project board', function(done) { | ||
var activeStories = [{story:{id:42,title:"Active story"}}]; | ||
var pastIterations = [{start_date:"2018/03/19",end_date:"2018/03/25",points:3,iteration_number:2}]; | ||
var dataHash = {active_stories: activeStories, past_iterations: pastIterations} | ||
var server = sinon.fakeServer.create(); | ||
server.respondImmediately = true; | ||
server.respondWith( | ||
"GET", "/project_boards/1337", [ | ||
200, {"Content-Type": "application/json"}, | ||
JSON.stringify(dataHash) | ||
] | ||
describe('fetch', function () { | ||
it('should update the past iterations and stories of the project board', function (done) { | ||
var activeStories = [{ story: { id: 42, title: 'Active story' } }]; | ||
var pastIterations = [ | ||
{ | ||
start_date: '2018/03/19', | ||
end_date: '2018/03/25', | ||
points: 3, | ||
iteration_number: 2, | ||
}, | ||
]; | ||
var dataHash = { | ||
active_stories: activeStories, | ||
past_iterations: pastIterations, | ||
}; | ||
server.use( | ||
http.get('/project_boards/1337', () => { | ||
return HttpResponse.json(dataHash), { status: 200 }; | ||
}) | ||
); | ||
|
||
var initialPastIterationsLength = projectBoard.pastIterations.length; | ||
|
||
var initialActiveStoriesLength = projectBoard.stories.length | ||
var initialActiveStoriesLength = projectBoard.stories.length; | ||
|
||
projectBoard.fetch() | ||
.then(() => { | ||
expect(projectBoard.pastIterations.length).toEqual(initialPastIterationsLength + 1); | ||
expect(projectBoard.stories.length).toEqual(initialActiveStoriesLength + 1); | ||
done(); | ||
}); | ||
projectBoard.fetch().then(() => { | ||
expect(projectBoard.pastIterations.length).toEqual( | ||
initialPastIterationsLength + 1 | ||
); | ||
expect(projectBoard.stories.length).toEqual( | ||
initialActiveStoriesLength + 1 | ||
); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.