-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5ade1de
commit dc24b4e
Showing
12 changed files
with
166 additions
and
38 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
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,55 @@ | ||
// | ||
// BaseURLTests.swift | ||
// SwiftLinkPreviewTests | ||
// | ||
// Created by Leonardo Cardoso on 23.09.21. | ||
// Copyright © 2021 leocardz.com. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
@testable import SwiftLinkPreview | ||
|
||
// This class tests head meta info | ||
class BaseURLTests: XCTestCase { | ||
|
||
// MARK: - Vars | ||
var baseTemplate = "" | ||
let slp = SwiftLinkPreview() | ||
|
||
// MARK: - SetUps | ||
// Those setup functions get that template, and fulfil determinated areas with rand texts, images and tags | ||
override func setUp() { | ||
super.setUp() | ||
|
||
self.baseTemplate = File.toString(Constants.headMetaBase) | ||
|
||
} | ||
|
||
// MARK: - Base | ||
func setUpBaseAndRun() { | ||
|
||
var baseTemplate = self.baseTemplate | ||
baseTemplate = baseTemplate.replace(Constants.headRandom, with: String.randomTag()) | ||
baseTemplate = baseTemplate.replace(Constants.bodyRandom, with: String.randomTag()).extendedTrim | ||
|
||
let result = self.slp.crawlMetaBase(baseTemplate, result: Response()) | ||
|
||
XCTAssertEqual(result.baseURL, "https://host/resource/index/") | ||
} | ||
|
||
func testBase() { | ||
|
||
for _ in 0 ..< 100 { | ||
|
||
self.setUpBaseAndRun() | ||
|
||
} | ||
|
||
} | ||
|
||
func testResultBase() { | ||
XCTAssertEqual(slp.formatImageURLs(["assets/test.png"], base: "https://host/resource/index/")?.first, | ||
"https://host/resource/index/assets/test.png") | ||
} | ||
|
||
} |
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,10 @@ | ||
<html> | ||
<head> | ||
[:head-random] | ||
<base href="https://host/resource/index/" target="_self"> | ||
</head> | ||
<body> | ||
[:body-random] | ||
<img src="assets/test.png"> | ||
</body> | ||
</html> |
Oops, something went wrong.