forked from CodeForPoznan/alinka-electron
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CodeForPoznan#121] Virtual field [WiP]
- Loading branch information
Showing
5 changed files
with
49 additions
and
29 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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const { sequelize } = require("../../db/db_config"); | ||
const schoolFactory = require("../factories/schoolFactory"); | ||
const {schoolData} = require("../factories/schoolFactory"); | ||
const schoolTypeFactory = require("../factories/schoolTypeFactory"); | ||
const truncate = require("../truncate"); | ||
const { School, SchoolType } = require("../../db/models"); | ||
|
||
describe("School model", () => { | ||
|
||
beforeEach(async () => { | ||
await truncate([School, SchoolType]); | ||
await schoolTypeFactory("przedszkole") | ||
}); | ||
|
||
afterEach(async () => { | ||
await truncate([School, SchoolType]); | ||
}); | ||
|
||
it("should be created", async () => { | ||
const school = await sequelize | ||
.sync({ force: true }) | ||
.then(() => schoolFactory({ name: "TEST", type: "przedszkole" })); | ||
|
||
expect(school).toBeTruthy(); | ||
expect(school.dataValues.name).toBe("TEST"); | ||
}); | ||
|
||
it("should return concatenated data by calling `address`", async () => { | ||
const school = await sequelize | ||
.sync({ force: true }) | ||
.then(() => schoolFactory({ street: "TEST STREET", type: "przedszkole" })); | ||
|
||
expect(school).toBeTruthy(); | ||
expect(school.dataValues.address).toBe("TEST STREET"); | ||
}); | ||
}); |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
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,3 +1,10 @@ | ||
module.exports = async function truncate(model) { | ||
model.destroy({ where: {}, force: true }); | ||
module.exports = async function truncate(models) { | ||
if (models instanceof Array){ | ||
models.map( | ||
model => model.destroy({ where: {}, force: true }) | ||
); | ||
} | ||
else { | ||
models.destroy({ where: {}, force: true }); | ||
} | ||
}; |