Skip to content

Commit

Permalink
Use constants as name
Browse files Browse the repository at this point in the history
  • Loading branch information
akaDuality committed Jul 2, 2023
1 parent 697b729 commit b7ee361
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions Shared/Tests/DocumentTests/Document/DocumentVersionsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,36 @@ import DocumentTestHelpers
import SnapshotTesting
import FolderSnapshot

typealias FileSample = String
extension FileSample {
static var beta = "BetaVersionFormat"
static var frame = "FrameVersionFormat"
static var artboard = "ArtboardFormat"
}

final class DocumentVersionsTests: XCTestCase {

#if os(macOS)

// MARK: - Beta format
func test_betaDocument_whenRead_shouldUpdateStructure() throws {
let document = try XCTUnwrap(Sample().document(name: "BetaVersionFormat", testCase: self))
let document = try XCTUnwrap(Sample().document(name: .beta, testCase: self))

// Read on file creation

assertSnapshot(matching: document.fileURL!, as: .folderStructure)
}

func test_betaDocument_whenSave_shouldUpdateStructure() throws {
let document = try XCTUnwrap(Sample().document(name: "BetaVersionFormat", testCase: self))
let document = try XCTUnwrap(Sample().document(name: .beta, testCase: self))

saveDocumentAndRemoveAtTearDown(document: document, name: "BetaFormatNewStructure")

assertSnapshot(matching: document.fileURL!, as: .folderStructure)
}

func test_betaDocument_whenRead_shouldMoveElementsToFirstFrame() throws {
let document = try XCTUnwrap(Sample().document(name: "BetaVersionFormat", testCase: self))
let document = try XCTUnwrap(Sample().document(name: .beta, testCase: self))

let frame = try XCTUnwrap(document.artboard.frames.first)

Expand All @@ -40,23 +47,23 @@ final class DocumentVersionsTests: XCTestCase {

// MARK: - Frame version
func test_frameDocument_whenRead_shouldUpdateStructure() throws {
let document = try XCTUnwrap(Sample().document(name: "FrameVersionFormat", testCase: self))
let document = try XCTUnwrap(Sample().document(name: .frame, testCase: self))

// Read on file creation

assertSnapshot(matching: document.fileURL!, as: .folderStructure)
}

func test_frameDocument_whenSave_shouldUpdateStructure() throws {
let document = try XCTUnwrap(Sample().document(name: "FrameVersionFormat", testCase: self))
let document = try XCTUnwrap(Sample().document(name: .frame, testCase: self))

saveDocumentAndRemoveAtTearDown(document: document, name: "FrameFormatNewStructure")

assertSnapshot(matching: document.fileURL!, as: .folderStructure)
}

func test_frameDocument_whenRead_shouldReadAsFirstFrame() throws {
let document = try XCTUnwrap(Sample().document(name: "FrameVersionFormat", testCase: self))
let document = try XCTUnwrap(Sample().document(name: .frame, testCase: self))

let frame = try XCTUnwrap(document.artboard.frames.first)

Expand All @@ -69,23 +76,23 @@ final class DocumentVersionsTests: XCTestCase {

// MARK: Artboard version
func test_artboardDocument_whenRead_shouldUpdateStructure() throws {
let document = try XCTUnwrap(Sample().document(name: "ArtboardFormat", testCase: self))
let document = try XCTUnwrap(Sample().document(name: .artboard, testCase: self))

// Read on file creation

assertSnapshot(matching: document.fileURL!, as: .folderStructure)
}

func test_artboardDocument_whenSave_shouldUpdateStructure() throws {
let document = try XCTUnwrap(Sample().document(name: "ArtboardFormat", testCase: self))
let document = try XCTUnwrap(Sample().document(name: .artboard, testCase: self))

saveDocumentAndRemoveAtTearDown(document: document, name: "ArtboardFormatNewStructure")

assertSnapshot(matching: document.fileURL!, as: .folderStructure)
}

func test_artboardDocument_whenRead_shouldReadContent() throws {
let document = try XCTUnwrap(Sample().document(name: "ArtboardFormat", testCase: self))
let document = try XCTUnwrap(Sample().document(name: .artboard, testCase: self))

let artboard = document.artboard
XCTAssertEqual(artboard.frames.count, 2)
Expand Down Expand Up @@ -129,8 +136,7 @@ final class DocumentVersionsTests: XCTestCase {
#elseif os(iOS)

func test_canReadDocumentWithoutFrameFolder() async throws {
let fileName = "BetaVersionFormat"
let document = try XCTUnwrap(Sample().document(name: fileName))
let document = try XCTUnwrap(Sample().document(name: .beta))

await document.read()

Expand All @@ -142,8 +148,7 @@ final class DocumentVersionsTests: XCTestCase {
}

func test_canReadFrameFileFolrmat() async throws {
let fileName = "ReleaseVersionFormat"
let document = try XCTUnwrap(Sample().document(name: fileName))
let document = try XCTUnwrap(Sample().document(name: .frame))

await document.read()

Expand Down

0 comments on commit b7ee361

Please sign in to comment.