Skip to content

Commit

Permalink
relocated and updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton Horn committed Feb 23, 2019
1 parent 17371e7 commit ec49ed2
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 163 deletions.
163 changes: 0 additions & 163 deletions app/assets/scripts/modules/reducers/repositories.test.js

This file was deleted.

48 changes: 48 additions & 0 deletions test/reducers/languages.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

import deepFreeze from "deep-freeze";
import reducer from "../../app/assets/scripts/modules/reducers/languages";
import ActionType from "../../app/assets/scripts/modules/actions/ActionType";

describe("reducer-languages", () => {
it("should handle RECEIVE_REPOSITORY_LANGUAGES action", () => {
const stateBefore = [
{
repositoryId: "kh123k",
isFetching: false,
errorMessage: null,
data: [ "CSS", "Html", "Javascript" ]
},
{
repositoryId: "sdfr3sy",
isFetching: false,
errorMessage: null,
data: [ "CSS", "Javascript", "PHP" ]
}
]
const stateAfter = [
{
repositoryId: "kh123k",
isFetching: false,
errorMessage: null,
data: [ "CSS", "Html", "Javascript" ]
},
{
repositoryId: "sdfr3sy",
isFetching: false,
errorMessage: null,
data: [ "C++", "PHP", "Python" ]
}
];

const action = {
type: ActionType.RECEIVE_REPOSITORY_LANGUAGES,
repositoryId: "sdfr3sy",
data: [ "C++", "PHP", "Python" ]
}

deepFreeze(stateBefore);
deepFreeze(action);

expect(reducer(stateBefore, action)).toEqual(stateAfter);
});
});
59 changes: 59 additions & 0 deletions test/reducers/repositories.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import deepFreeze from "deep-freeze";
import reducer from "../../app/assets/scripts/modules/reducers/repositories";
import ActionType from "../../app/assets/scripts/modules/actions/ActionType";

describe("reducer-repositories", () => {

it("should handle RECEIVE_REPOSITORIES action", () => {
const stateBefore = {
username: "friend",
isFetching: false,
errorMessage: null,
data: []
};

const stateAfter = {
username: "friend",
isFetching: false,
errorMessage: null,
data: [
{
id: "kh123k",
name: "",
description: "",
website: ""
},
{
id: "82jd9jk",
name: "",
description: "",
website: ""
}
]
};

const action = {
type: ActionType.RECEIVE_REPOSITORIES,
username: "friend",
data: [
{
id: "kh123k",
name: "",
description: "",
website: ""
},
{
id: "82jd9jk",
name: "",
description: "",
website: ""
}
]
};

deepFreeze(stateBefore);
deepFreeze(action);

expect(reducer(stateBefore, action)).toEqual(stateAfter);
});
});

0 comments on commit ec49ed2

Please sign in to comment.