-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now we just try to quickly get the date into a yyyy-mm-dd format, and don't mess with it after that. Had to change tsconfig settings and how commonjs modules are imported in order to get both jest and the app to both be happy with moment. See aurelia/skeleton-navigation#606
- Loading branch information
Showing
11 changed files
with
189 additions
and
78 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
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
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,57 @@ | ||
import { ProjectMetadataFile } from "../Project/Project"; | ||
import * as temp from "temp"; | ||
import fs from "fs"; | ||
import Path from "path"; | ||
|
||
let projectDirectory; | ||
let projectName; | ||
|
||
describe("Project Read", () => { | ||
beforeEach(async () => { | ||
projectDirectory = temp.mkdirSync("test"); | ||
projectName = Path.basename(projectDirectory); | ||
}); | ||
afterEach(async () => { | ||
temp.cleanupSync(); | ||
}); | ||
it("should read title", () => { | ||
const f = GetProjectFileWithOneField("Title", "This is the title."); | ||
expect(f.getTextProperty("title")).toBe("This is the title."); | ||
}); | ||
it("empty date should just be empty string", () => { | ||
const f = GetProjectFileWithOneField("DateAvailable", ""); | ||
expect(f.properties.getDateField("dateAvailable").asISODateString()).toBe( | ||
"" | ||
); | ||
}); | ||
it("should read iso date properly", () => { | ||
const f = GetProjectFileWithOneField("DateAvailable", "2015-03-05"); | ||
expect(f.properties.getDateField("dateAvailable").asISODateString()).toBe( | ||
"2015-03-05" | ||
); | ||
}); | ||
it("should read iso date with time and offset properly", () => { | ||
const f = GetProjectFileWithOneField( | ||
"DateAvailable", | ||
"2016-01-01T00:00:00+02:00" | ||
); | ||
// The original says it's at midnight in a timezone 2 hours ahead of UTC. | ||
// In SayMore we don't want to deal with timezones, so we convert that to | ||
// UTC, which is actually the previous day, drop the time, drop the time offset. | ||
expect(f.properties.getDateField("dateAvailable").asISODateString()).toBe( | ||
"2015-12-31" | ||
); | ||
}); | ||
}); | ||
|
||
function GetProjectFileWithOneField( | ||
tag: string, | ||
content: string | ||
): ProjectMetadataFile { | ||
fs.writeFileSync( | ||
Path.join(projectDirectory, projectName + ".sprj"), | ||
`<?xml version="1.0" encoding="utf-8"?> | ||
<Project><${tag}>${content}</${tag}></Project>` | ||
); | ||
return new ProjectMetadataFile(projectDirectory); | ||
} |
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
Oops, something went wrong.