Skip to content

Commit

Permalink
fix: add tests for light and dark asset processor cases
Browse files Browse the repository at this point in the history
  • Loading branch information
JonLz authored and subdan committed Feb 14, 2021
1 parent d9921f0 commit ee88c5c
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions Tests/FigmaExportTests/AssetsProcessorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,54 @@ final class AssetsProcessorTests: XCTestCase {

XCTAssertThrowsError(try processor.process(assets: images).get())
}

// Light count can exceed dark count
func testProcessWithUniversalAsset() throws {
let lights = [
Color(name: "primaryText", platform: .ios, red: 0, green: 0, blue: 0, alpha: 0),
Color(name: "primaryLink", platform: .ios, red: 0, green: 0, blue: 0, alpha: 0)
]

let darks = [
Color(name: "primaryText", platform: .ios, red: 0, green: 0, blue: 0, alpha: 0)
]

let processor = ColorsProcessor(
platform: .ios,
nameValidateRegexp: nil,
nameReplaceRegexp: nil,
nameStyle: .camelCase,
useSingleFile: false,
darkModeSuffix: ""
)
let colors = try processor.process(light: lights, dark: darks).get()

XCTAssertEqual(
[colors.compactMap { $0.light.name }, colors.compactMap { $0.dark?.name }],
[["primaryLink", "primaryText"], ["primaryText"]]
)
}

// Dark count cannot exceed light count
func testProcessWithUniversalAsset2() throws {
let lights = [
Color(name: "primaryText", platform: .ios, red: 0, green: 0, blue: 0, alpha: 0),
]

let darks = [
Color(name: "primaryText", platform: .ios, red: 0, green: 0, blue: 0, alpha: 0),
Color(name: "primaryLink", platform: .ios, red: 0, green: 0, blue: 0, alpha: 0)
]

let processor = ColorsProcessor(
platform: .ios,
nameValidateRegexp: nil,
nameReplaceRegexp: nil,
nameStyle: .camelCase,
useSingleFile: false,
darkModeSuffix: ""
)

XCTAssertThrowsError(try processor.process(light: lights, dark: darks).get())
}
}

0 comments on commit ee88c5c

Please sign in to comment.