-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: data model, stubs and test for units
- Loading branch information
Showing
5 changed files
with
221 additions
and
21 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
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,11 +1,73 @@ | ||
'use strict'; | ||
import Sequelize from 'sequelize'; | ||
const { DataTypes, Model } = Sequelize; | ||
import { sequelize } from '../database'; | ||
|
||
class Unit extends Model { } | ||
|
||
|
||
class UnitModel { | ||
static list(page = 0, limit = 10) { | ||
return stub; | ||
Unit.init({ | ||
id: { | ||
allowNull: false, | ||
autoIncrement: true, | ||
primaryKey: true, | ||
type: Sequelize.INTEGER | ||
}, | ||
buyer: { | ||
type: Sequelize.STRING | ||
}, | ||
registry: { | ||
type: Sequelize.STRING | ||
}, | ||
blockIdentifier: { | ||
type: Sequelize.STRING | ||
}, | ||
identifier: { | ||
type: Sequelize.STRING | ||
}, | ||
unitType: { | ||
type: Sequelize.STRING | ||
}, | ||
unitCount: { | ||
type: Sequelize.NUMBER | ||
}, | ||
unitStatus: { | ||
type: Sequelize.STRING | ||
}, | ||
unitStatusDate: { | ||
type: Sequelize.DATE | ||
}, | ||
transactionType: { | ||
type: Sequelize.STRING | ||
}, | ||
unitIssuanceLocation: { | ||
type: Sequelize.STRING | ||
}, | ||
unitLink: { | ||
type: Sequelize.STRING | ||
}, | ||
correspondingAdjustment: { | ||
type: Sequelize.STRING | ||
}, | ||
unitTag: { | ||
type: Sequelize.STRING | ||
}, | ||
vintageId: { | ||
type: Sequelize.NUMBER | ||
}, | ||
qualificationId: { | ||
type: Sequelize.NUMBER | ||
}, | ||
owner: { | ||
type: Sequelize.STRING | ||
}, | ||
createdAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE | ||
}, | ||
updatedAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE | ||
} | ||
} | ||
}, { sequelize, modelName: 'qualification' }); | ||
|
||
export { UnitModel }; | ||
export { Unit }; |
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 +1,107 @@ | ||
[] | ||
[ | ||
{ | ||
"id": 1, | ||
"unitLink": "https://unit.link", | ||
"owner": "owner", | ||
"buyer": "person 1", | ||
"registry": "registry 1", | ||
"blockIdentifier": "bi 1", | ||
"identifier": "i 1", | ||
"qualificationId": 10, | ||
"unitType": "regular", | ||
"unitCount": 10, | ||
"unitStatus": "draft", | ||
"unitStatusDate": "2022-11-05T14:41:00.000Z", | ||
"transactionType": "purchase", | ||
"unitIssuanceLocation": "public", | ||
"correspondingAdjustment": "1", | ||
"unitTag": "tag1", | ||
"vintageId": 1, | ||
"createdAt": "2022-11-05T14:41:00.000Z", | ||
"updatedAt": "2022-11-05T14:41:00.000Z" | ||
}, | ||
{ | ||
"id": 2, | ||
"unitLink": "https://unit.link", | ||
"owner": "owner", | ||
"buyer": "person 2", | ||
"registry": "registry 2", | ||
"blockIdentifier": "bi 2", | ||
"identifier": "i 2", | ||
"qualificationId": 14, | ||
"unitType": "regular", | ||
"unitCount": 10, | ||
"unitStatus": "draft", | ||
"unitStatusDate": "2020-11-05T14:41:00.000Z", | ||
"transactionType": "purchase", | ||
"unitIssuanceLocation": "public", | ||
"correspondingAdjustment": "1", | ||
"unitTag": "tag2", | ||
"vintageId": 1, | ||
"createdAt": "2020-11-05T14:41:00.000Z", | ||
"updatedAt": "2020-11-05T14:41:00.000Z" | ||
}, | ||
{ | ||
"id": 3, | ||
"unitLink": "https://unit.link", | ||
"owner": "owner", | ||
"buyer": "person 3", | ||
"registry": "registry 3", | ||
"blockIdentifier": "bi 3", | ||
"identifier": "i 3", | ||
"qualificationId": 14, | ||
"unitType": "regular", | ||
"unitCount": 14, | ||
"unitStatus": "published", | ||
"unitStatusDate": "2021-11-05T14:41:00.000Z", | ||
"transactionType": "purchase", | ||
"unitIssuanceLocation": "public", | ||
"correspondingAdjustment": "1", | ||
"unitTag": "tag3", | ||
"vintageId": 1, | ||
"createdAt": "2021-11-05T14:41:00.000Z", | ||
"updatedAt": "2021-11-05T14:41:00.000Z" | ||
}, | ||
{ | ||
"id": 4, | ||
"unitLink": "https://unit.link", | ||
"owner": "owner", | ||
"buyer": "person 4", | ||
"registry": "registry 4", | ||
"blockIdentifier": "bi 4", | ||
"identifier": "i 4", | ||
"qualificationId": 14, | ||
"unitType": "regular", | ||
"unitCount": 14, | ||
"unitStatus": "published", | ||
"unitStatusDate": "2025-11-05T14:41:00.000Z", | ||
"transactionType": "purchase", | ||
"unitIssuanceLocation": "public", | ||
"correspondingAdjustment": "1", | ||
"unitTag": "tag4", | ||
"vintageId": 1, | ||
"createdAt": "2025-11-05T14:41:00.000Z", | ||
"updatedAt": "2025-11-05T14:41:00.000Z" | ||
}, | ||
{ | ||
"id": 5, | ||
"unitLink": "https://unit.link", | ||
"owner": "owner", | ||
"buyer": "person 5", | ||
"registry": "registry 5", | ||
"blockIdentifier": "bi 5", | ||
"identifier": "i 5", | ||
"qualificationId": 14, | ||
"unitType": "regular", | ||
"unitCount": 9, | ||
"unitStatus": "published", | ||
"unitStatusDate": "2030-11-05T14:41:00.000Z", | ||
"transactionType": "purchase", | ||
"unitIssuanceLocation": "public", | ||
"correspondingAdjustment": "1", | ||
"unitTag": "tag4", | ||
"vintageId": 1, | ||
"createdAt": "2030-11-05T14:41:00.000Z", | ||
"updatedAt": "2030-11-05T14:41:00.000Z" | ||
} | ||
] |
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,30 @@ | ||
import chai from 'chai'; | ||
import chaiHttp from 'chai-http'; | ||
import app from './../../src/server'; | ||
|
||
// Configure chai | ||
chai.use(chaiHttp); | ||
chai.should(); | ||
|
||
describe("Units Routes", () => { | ||
describe("GET /v1/units/", () => { | ||
it("should get all units", () => { | ||
chai.request(app) | ||
.get('/v1/units/?useMock=true') | ||
.end((err, res) => { | ||
res.should.have.status(200); | ||
res.body.should.be.a('array'); | ||
}); | ||
}); | ||
}); | ||
describe("GET /v1/units/?id=1", () => { | ||
it("should get a single unit", () => { | ||
chai.request(app) | ||
.get('/v1/units/?useMock=true&id=1') | ||
.end((err, res) => { | ||
res.should.have.status(200); | ||
res.body.should.be.a('object'); | ||
}); | ||
}); | ||
}); | ||
}); |