-
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.
Capture behaviour of old diff library
You can see that the diffs were not perfect! If there was no change, double commas showed, and if there _was_ a diff, ANSI colour codes were only partially removed, leaving behind a 0x1B ('ANSI Escape') character. https://en.wikipedia.org/wiki/ANSI_escape_code#C0_control_codes
- Loading branch information
Showing
2 changed files
with
60 additions
and
0 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,57 @@ | ||
package model.commands | ||
|
||
import com.gu.media.model.{Category, ContentChangeDetails, MediaAtom} | ||
import model.commands.UpdateAtomCommand.createDiffString | ||
import org.scalatest.{FunSuite, MustMatchers} | ||
|
||
class UpdateAtomCommandTest extends FunSuite with MustMatchers { | ||
val mediaAtomFixture: MediaAtom = MediaAtom( | ||
id = "123", | ||
labels = List.empty, | ||
assets = List.empty, | ||
activeVersion = Some(1), | ||
title = "title", | ||
category = Category.News, | ||
description = Some("Example description"), | ||
duration = Some(1), | ||
source = Some("source"), | ||
posterImage = None, | ||
trailText = None, | ||
youtubeTitle = "title", | ||
youtubeDescription = None, | ||
trailImage = None, | ||
tags = List.empty, | ||
byline = List.empty, | ||
commissioningDesks = List.empty, | ||
contentChangeDetails = ContentChangeDetails(None, None, None, 1L, None, None, None), | ||
privacyStatus = None, | ||
channelId = None, | ||
youtubeCategoryId = None, | ||
youtubeOverrideImage = None, | ||
keywords = List.empty, | ||
license = None, | ||
plutoData = None, | ||
expiryDate = None, | ||
legallySensitive = None, | ||
sensitive = None, | ||
optimisedForWeb = None, | ||
composerCommentsEnabled = None, | ||
suppressRelatedContent = None | ||
) | ||
|
||
test("Diff output when nothing changes") { | ||
createDiffString(mediaAtomFixture, mediaAtomFixture) must be("Updated atom fields (category = News$,, channelId = None,, description = Some( \"Example description\" ),, duration = Some( 1 ),, legallySensitive = None,, license = None,, source = Some( \"source\" ),, title = \"title\",, youtubeCategoryId = None,, youtubeTitle = \"title\")") | ||
} | ||
|
||
test("Diff output when description changes") { | ||
createDiffString(mediaAtomFixture, mediaAtomFixture.copy(description = Some("New description"))) must be( | ||
"Updated atom fields (MediaAtom( ..., description = Some( \u001B\"Example description\"\u001B -> \u001B\"New description\"\u001B ) ))" | ||
) | ||
} | ||
|
||
test("Diff output when description is removed") { | ||
createDiffString(mediaAtomFixture, mediaAtomFixture.copy(description = None)) must be( | ||
"Updated atom fields (MediaAtom( ..., description = \u001BSome( \"Example description\" )\u001B -> \u001BNone\u001B ))" | ||
) | ||
} | ||
} |